package com.yh.csx.etl.config;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * ETL Mapping Conifg
 * 
 * @author Robin.Wang
 * @date 2020-03-18
 *
 */
public class EtlDataMapping {
    private String dataSourceKey; // 数据源key
    private String outerSourceKey; // 对应适配器的key
    private boolean concurrent = false; // 是否并行同步
    private String mode;// 模式（同库、异库）
    private String groupId;// 分组
    private String cron;// 任务计划
    private DbMapping dbMapping;// 配置表

    public String getDataSourceKey() {
        return dataSourceKey;
    }

    public void setDataSourceKey(String dataSourceKey) {
        this.dataSourceKey = dataSourceKey;
    }

    public String getOuterSourceKey() {
        return outerSourceKey;
    }

    public void setOuterSourceKey(String outerSourceKey) {
        this.outerSourceKey = outerSourceKey;
    }

    public boolean isConcurrent() {
        return concurrent;
    }

    public void setConcurrent(boolean concurrent) {
        this.concurrent = concurrent;
    }

    public String getMode() {
        return mode;
    }

    public void setMode(String mode) {
        this.mode = mode;
    }

    public String getCron() {
        return cron;
    }

    public void setCron(String cron) {
        this.cron = cron;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public DbMapping getDbMapping() {
        return dbMapping;
    }

    public void setDbMapping(DbMapping dbMapping) {
        this.dbMapping = dbMapping;
    }

    public static class DbMapping {
        private String database; // 数据库名或schema名
        private String table; // 表名
        private Map<String, String> targetPk = new LinkedHashMap<>(); // 目标表主键字段
        private boolean mapAll = false; // 映射所有字段
        private Integer relationLayer = 0;
        private String keepPeriod = "30Day"; // 默认处理30天前的数据
        private String etlPeriod = "1Day"; // 处理数据
        private String splitType; // 拆分表类型SplitTypeEnum
        private String splitSuffixFormat;// 拆分表名后缀规则
        private String targetDb; // 目标库名
        private String targetTable; // 目标表名
        private Map<String, String> targetColumns; // 目标表字段映射
        private String etlCondition; // etl条件sql
        private int readBatch = 5000;
        private int commitBatch = 5000; // etl等批量提交大小

        private Map<String, String> allMapColumns;

        public String getDatabase() {
            return database;
        }

        public void setDatabase(String database) {
            this.database = database;
        }

        public String getEtlPeriod() {
            return etlPeriod;
        }

        public void setEtlPeriod(String etlPeriod) {
            this.etlPeriod = etlPeriod;
        }

        public String getKeepPeriod() {
            return keepPeriod;
        }

        public void setKeepPeriod(String keepPeriod) {
            this.keepPeriod = keepPeriod;
        }

        public String getSplitType() {
            return splitType;
        }

        public void setSplitType(String splitType) {
            this.splitType = splitType;
        }

        public String getSplitSuffixFormat() {
            return splitSuffixFormat;
        }

        public void setSplitSuffixFormat(String splitSuffixFormat) {
            this.splitSuffixFormat = splitSuffixFormat;
        }

        public String getTable() {
            return table;
        }

        public void setTable(String table) {
            this.table = table;
        }

        public Map<String, String> getTargetPk() {
            return targetPk;
        }

        public void setTargetPk(Map<String, String> targetPk) {
            this.targetPk = targetPk;
        }

        public boolean isMapAll() {
            return mapAll;
        }

        public void setMapAll(boolean mapAll) {
            this.mapAll = mapAll;
        }

        public String getTargetDb() {
            return targetDb;
        }

        public void setTargetDb(String targetDb) {
            this.targetDb = targetDb;
        }

        public String getTargetTable() {
            return targetTable;
        }

        public void setTargetTable(String targetTable) {
            this.targetTable = targetTable;
        }

        public Map<String, String> getTargetColumns() {
            return targetColumns;
        }

        public void setTargetColumns(Map<String, String> targetColumns) {
            this.targetColumns = targetColumns;
        }

        public String getEtlCondition() {
            return etlCondition;
        }

        public void setEtlCondition(String etlCondition) {
            this.etlCondition = etlCondition;
        }

        public int getReadBatch() {
            return readBatch;
        }

        public void setReadBatch(int readBatch) {
            this.readBatch = readBatch;
        }

        public int getCommitBatch() {
            return commitBatch;
        }

        public void setCommitBatch(int commitBatch) {
            this.commitBatch = commitBatch;
        }

        public Map<String, String> getAllMapColumns() {
            return allMapColumns;
        }

        public void setAllMapColumns(Map<String, String> allMapColumns) {
            this.allMapColumns = allMapColumns;
        }

        public Integer getRelationLayer() {
            return relationLayer;
        }

        public void setRelationLayer(Integer relationLayer) {
            this.relationLayer = relationLayer;
        }

    }
}
